package goleetcode

func tupleSameProduct(nums []int) int {
	n := len(nums)
	cnt := make(map[int]int)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			key := nums[i] * nums[j]
			cnt[key]++
		}
	}
	var ans int
	for _, v := range cnt {
		ans += v * (v - 1) * 4
	}
	return ans
}